package com.situ.crm.controller.back;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.crm.common.ServerResponse;
import com.situ.crm.entity.SaleChance;
import com.situ.crm.service.IOrderService;
import com.situ.crm.service.ISaleChanceService;

@Controller
@RequestMapping("/order")
public class OrderController {

	@Autowired
	private IOrderService orderService; 
	@Autowired
	private ISaleChanceService saleChanceService; 
	//跳转到订单展示界面
	@RequestMapping("/getPage")
	public String getPage() {
		
		return "/order/order";
	}
	//数据接口
	//订单界面数据 + 分页
	@RequestMapping("/pageList")
	@ResponseBody
	public ServerResponse pageList(Integer page,Integer limit) {
		ServerResponse serverResponse = orderService.pageList(page, limit);
		
		return serverResponse;
	}
	//添加
	@RequestMapping("/insert")
	@ResponseBody
	public ServerResponse insert (Integer id) {
		System.out.println("开发界面传来的 = "+id);
		//在salechance表中查询 客户id 商品id 
		SaleChance saleChance = saleChanceService.selectById(id);
		//成功 可以打印
		System.out.println(saleChance);
		//取出所属客户id
		Integer customerId = saleChance.getCustomerId();
		//取出营销机会id
		Integer saleChanceId = saleChance.getId();
		
		//添加
		ServerResponse serverResponse =orderService.insert(id); 
		return serverResponse;
	}
}
